<!DOCTYPE html>

<html>
    <head>
        <title>Agenda</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="css/bootstrap.css" rel="stylesheet">
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
  	<link href="css/stilo.css" rel="stylesheet">
    <link href="css/agenda.css" rel="stylesheet">
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="js/html5shiv.js"></script>
        <![endif]-->
    </head>
    <body>
       <div class="container">
           <?php include "topo.html"; ?>
           <?php include "menu.php"; ?>
           
           
		<section><!-- ----------------------------------------Inicio do Conteudo----------------------------------- -->
			<div id="conteudo">
				<div class="row-fluid">
					<div class="span12">
						<div class="titulo">
                                                    <p><b>Agenda do(a) Especialista: <?php echo $nomeprofissional; ?></b></p>
						</div>
						<div class="bordas">
                                                    <div class="span3">
                                                        <?php

                                                              print '<table class="tabela" >';//construção do calendario

                                                              print '<tr>';

                                                              print '<td class="mes"><a href="?pg=EspecialidadeAgenda&id='.$idprofissional.'&data='.$primeiro.'/'.$mes_ant.'/'.$ano_ant.'" title="Mês anterior">  &laquo; </a></td>';/*mês anterior*/

                                                              print '<td class="mes" colspan="5">'.$mes.'/'.$ano.'</td>';/*mes atual e ano*/

                                                              print '<td class="mes"><a href="?pg=EspecialidadeAgenda&id='.$idprofissional.'&data='.$primeiro.'/'.$mes_prox.'/'.$ano_prox.'" title="Próximo mês">  &raquo; </a></td>';/*Proximo mês*/

                                                              print '</tr><tr>';

                                                              print '<td class="sem">D</td>';//printar os dias da semana

                                                              print '<td class="sem">S</td>';

                                                              print '<td class="sem">T</td>';

                                                              print '<td class="sem">Q</td>';

                                                              print '<td class="sem">Q</td>';

                                                              print '<td class="sem">S</td>';

                                                              print '<td class="sem">S</td>';

                                                              print '</tr><tr>';

                                                              $dt = 1;

                                                              if($branco > 0){

                                                                  for($x = 0; $x < $branco; $x++){

                                                                       print '<td>&nbsp;</td>';/*preenche os espaços em branco*/

                                                                      $dt++;

                                                                  }

                                                              }

                                                              for($i = 1; $i <= $n; $i++ ){

                                                              if($dt == 1){/*imprime os domingos*/

                                                                  print '<td class="dom">';

                                                                  print $i;

                                                                  print '</td>';

                                                                  $dt++;

                                                              }else{/*imprime os dias normais*/

                                                                  print '<td class="td">';

                                                                  print '<a href="?pg=EspecialidadeAgenda&id='.$idprofissional.'&data='.$i.'/'.$month.'/'.$ano.'">'.$i.'</a>';

                                                                  print '</td>';

                                                                  $dt++;

                                                                      }

                                                              if($dt > 7){/*faz a quebra no sabado*/

                                                              print '</tr><tr>';

                                                              $dt = 1;

                                                              }
                                                              }


                                                          print '</tr>';

                                                          print '</table>';

                                                         
                                                          $calendario = $dia.'/'.$month.'/'.$ano;
                                                          ?>
                                                        </br></br>


                                                    </div>
                                                    <div class="span9">
                                                        <form class="form-horizontal agenda" method="POST" action="index.php?pg=InserirAgenda" >
                                                            <fieldset>
                                                                
                                                            <!-- Multiple Radios (inline) -->
                                                            <div class="control-group">
                                                              <label class="control-label" for="tipo">Atendimento</label>
                                                              <div class="controls">
                                                                <label class="radio inline" for="tipo-0">
                                                                  <input name="tipo" id="tipo-0" value="0" type="radio">
                                                                  Interno
                                                                </label>
                                                                <label class="radio inline" for="tipo-1">
                                                                  <input name="tipo" id="tipo-1" value="1" type="radio">
                                                                  Externo
                                                                </label>
                                                              </div>
                                                            </div> 
   
                                                            <!-- Text input-->
                                                            <div class="control-group">
                                                              <label class="control-label" for="data">Data</label>
                                                              <div class="controls">
                                                                  <input id="data" name="data" value="<?php echo $calendario; ?>" placeholder="" class="input-large" type="text">

                                                              </div>
                                                            </div>

                                                            <!-- Text input-->
                                                            <div class="control-group">
                                                              <label class="control-label" for="sus">Cartão do SUS</label>
                                                              <div class="controls">
                                                                <input id="sus" name="sus" placeholder="" class="input-large numeros" type="text">

                                                              </div>
                                                            </div>

                                                            <!-- Button -->
                                                            <div class="control-group">
                                                              <label class="control-label" for="pequisar"></label>
                                                              <div class="controls">
                                                                  <a href="javascript:abrir('index.php?pg=BuscarUsuario');" class="btn btn-info">Pesquisar Usuário</a>
                                                              </div>
                                                            </div>

                                                            <!-- Select Basic -->
                                                            <div class="control-group">
                                                              <label class="control-label" for="horario">Hora</label>
                                                              <div class="controls">
                                                                <select id="horario" name="horario" class="input-medium">
                                                                  <option value="" >Selecione</option>
                                                                  <option>8:00</option>
                                                                  <option>8:30</option>
                                                                  <option>9:00</option>
                                                                  <option>9:30</option>
                                                                  <option>10:00</option>
                                                                  <option>10:30</option>
                                                                  <option>13:00</option>
                                                                  <option>13:30</option>
                                                                  <option>14:00</option>
                                                                  <option>14:30</option>
                                                                  <option>15:00</option>
                                                                  <option>15:30</option>
                                                                  <option>16:00</option>
                                                                  <option>16:30</option>
                                                                
                                                                </select>
                                                              </div>
                                                            </div>

                                                            <!-- Textarea -->
                                                            <div class="control-group">
                                                              <label class="control-label" for="observacao">Observações</label>
                                                              <div class="controls">                     
                                                                <textarea id="observacao" name="observacao"></textarea>
                                                              </div>
                                                            </div>
                                                            
                                                            <!-- Text input-->
                                                            <div class="control-group">
                                                              
                                                              <div class="controls">
                                                                  <input id="idcargo" name="idcargo" placeholder="" value="<?php echo $idcargo[0]->idcargo; ?>" class="input-large" type="hidden">

                                                              </div>
                                                            </div>
                                                            
                                                            <!-- Text input-->
                                                            <div class="control-group">
                                                              
                                                              <div class="controls">
                                                                  <input id="idprofissional" name="idprofissional" placeholder="" value="<?php echo $idprofissional; ?>" class="input-large" type="hidden">

                                                              </div>
                                                            </div>

                                                            <!-- Button -->
                                                            <div class="control-group">
                                                              <label class="control-label" for="agendar"></label>
                                                              <div class="controls">
                                                                <button id="agendar" name="agendar" class="btn btn-primary">Agendar</button>
                                                              </div>
                                                            </div>

                                                            </fieldset>
                                                            </form>

                                                        
                                                    </div>
                                                    <div class="row-fluid">
                                                        <div class="span12 table-responsive">
                                                        <table class="table">
                                                            <tr><th colspan="8">Manhã</th></tr>
                                                            <tr>
                                                                <th> Data </th>
                                                                <th> 8:00 </th>
                                                                <th> 8:30 </th>
                                                                <th> 9:00 </th>
                                                                <th> 9:30 </th>
                                                                <th> 10:00 </th>
                                                                <th> 10:30 </th>
                                                            </tr>
                                                                    <?php
                                                                     for($i = 0; $i <= 4; $i++ ){
                                                                        $dataNova = date('d/m/Y', mktime(0,0,0, $month, $dia + $i, $ano));
                                                                        $databanco = date('y-m-d', mktime(0,0,0, $month, $dia + $i, $ano));
                                                                        echo '
                                                                            <tr> 
                                                                            <td>'.$dataNova.'</td>';
                                                                           for ($j = 1; $j < 7; $j++) {
                                                                            $verifica = new Cagenda();
                                                                            $verificar = $verifica->consultaagenda($databanco, $atender[$j], $idprofissional);
                                                                            echo '<td class="'; if($verificar[0]== TRUE) {echo 'vermelho';} else {echo 'verde';} echo'">'; 
                                                                            if($verificar[0] == FALSE){

                                                                            }
                                                                            if($verificar[0] == TRUE){
                                                                                echo '<p class="center">'.$verificar[1].'</p>';
                                                                            }
                                                                            echo'</td>';
                                                                        }
                                                                            echo '</tr>';
                                                                        }   
                                                                    ?>       
                                                        </table>
														</div>
														</div>
														<div class="row-fluid">
                                                       <div class="span12 table-responsive">
                                                        <table class="table">
                                                            <tr><th colspan="8">Tarde</th></tr>
                                                            <tr>
                                                                <th> Data </th>
                                                                <th> 13:00 </th>
                                                                <th> 13:30 </th>
                                                                <th> 14:00 </th>
                                                                <th> 14:30 </th>
                                                                <th> 15:00 </th>
                                                                <th> 15:30 </th>
                                                                <th> 16:00 </th>
                                                                <th> 16:30 </th>
                                                            </tr>
                                                                <?php
                                                                 for($i = 0; $i <= 4; $i++ ){
                                                                    $dataNova = date('d/m/Y', mktime(0,0,0, $month, $dia + $i, $ano));
                                                                    $databanco = date('y-m-d', mktime(0,0,0, $month, $dia + $i, $ano));
                                                                    echo '
                                                                        <tr> 
                                                                        <td>'.$dataNova.'</td>';
                                                                       for ($j = 7; $j < 15; $j++) {
                                                                        $verifica = new Cagenda();
                                                                        $letra = "A";
                                                                        $verificar = $verifica->consultaagenda($databanco, $atender[$j], $idprofissional);
                                                                        echo '<td class="'; if($verificar[0]== TRUE ) {echo 'vermelho';} else {echo 'verde';} echo'">'; 
                                                                        if($verificar[0] == FALSE){
                                                                            
                                                                        }
                                                                        if($verificar[0] == TRUE){
                                                                            echo '<p class="center"><a href="index.php?pg=StatusAgenda&id='.$verificar[2].'">'.$verificar[1].'</a></p>';
                                                                        }
                                                                        echo'</td>';
                                                                    }
                                                                        echo '</tr>';
                                                                    }   
                                                                ?>        
                                                        </table>
                                                        </div>
                                                    </div>
                                                        
                                                    </div>
						</div>
					</div>	
				</div>
			</div> <!-- Fim da linha conteudo -->
		</section><!-- ----------------------------------------fim do Conteudo----------------------------------- -->

           
           <?php include "rodape.html"; ?>
           
           
       </div><!-- fim da div container -->    
        
        
    <!-- Arquivos Javascripts ================================================== -->
    <script src="js/jquery-1.10.2.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.validate.js"></script>
    <script src="js/sonumeros.js"></script>
    <script src="js/popup.js"></script>
    <script src="js/jquery.maskedinput.js"></script>
    <script src="js/mascaras.js"></script>
    <script src="js/validaformagenda.js"></script>
    </body>
</html>

